﻿using Prism.Commands;
using Prism.Events;
using Prism.Regions;
using prismFramework_Modules.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace prismFramework_Modules.ViewModels
{
    public class ViewAViewModel : INavigationAware
    {
        private readonly IEventAggregator _eventAggregator;
        public ViewAViewModel(IEventAggregator eventAggregator)
        {
            _eventAggregator= eventAggregator; 

            
        }

        private DelegateCommand _sendMsg;
        public DelegateCommand SendMsg =>
            _sendMsg ?? (_sendMsg = new DelegateCommand(ExecuteSendMsg));

        void ExecuteSendMsg()
        {
            _eventAggregator.GetEvent<MsgEvent>().Publish("Hello Prism!");
        }

        /// <summary>
        /// 是否导航
        /// </summary>
        /// <param name="navigationContext"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
           // throw new NotImplementedException();
        }
        /// <summary>
        /// 导航前
        /// </summary>
        /// <param name="navigationContext"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
           // throw new NotImplementedException();
        }
        /// <summary>
        /// 导航后
        /// </summary>
        /// <param name="navigationContext"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
           // throw new NotImplementedException();
        }
    }
}
